from django.urls import path
from rest_framework.documentation import include_docs_urls



from apps.drf_test_8_ModelViewSet视图.views import BookModelViewSet

urlpatterns = [
    # path('books/',BookModelViewSet.as_view({"get":"list","post":"create"})),
    # path('books/<int:pk>',BookModelViewSet.as_view({"get":"retrieve","put":"update","delete":"destroy"})),
    # path('books/breadGT10/',BookModelViewSet.as_view({"get":"breadGT10"})),  # 映射方法 get() ---> breadGT10()
    # path('books/put_bread/<int:pk>',BookModelViewSet.as_view({"put":"put_bread"})),  # 映射方法 put() ---> put_bread()
    path('docs/', include_docs_urls(title="My API title")),  # pip install coreapi 自动生成接口文档

]


from rest_framework.routers import DefaultRouter,SimpleRouter

# route = DefaultRouter() #默认路由   包含 列表路由、详情路由、根路由等 含html视图或json格式数据返回
route = SimpleRouter()  #简单路由

route.register('books',BookModelViewSet,basename='books')
urlpatterns += route.urls
# print(urlpatterns)